@extends('admin.layouts.app')
@section('content')
    @can('create', App\Admin::class)
        <div class="row">
            <div class="col-sm-12 pb-10">
                <a href="{{ route('admin.create') }}" class="btn btn-white"><i class="fa fa-plus"></i>新增管理员</a>
            </div>
        </div>
    @endcan
    @component('admin.slots.table', ['page' => $admins])
        <thead>
        <tr>
            <th>id</th>
            <th>姓名</th>
            <th>邮箱</th>
            <th>创建时间</th>
            <th>最近更新</th>
            <th>操作</th>
        </tr>
        </thead>
        <tbody>
        @foreach($admins as $admin)
            <tr>
                <td>{{ $admin->id }}</td>
                <td>{{ $admin->name }}</td>
                <td>{{ $admin->email }}</td>
                <td>{{ $admin->created_at }}</td>
                <td>{{ $admin->updated_at }}</td>
                <td>
                    @can('update', $admin)
                        <a title="编辑" href="{{route('admin.edit', ['id' => $admin->id])}}"
                           class="text-navy ml-10"><i class="fa fa-edit"></i> 编辑</a>
                    @endcan
                    @can('delete', $admin)
                        <a title="删除" href="javascript:;"
                           onclick="if (window.confirm('确认删除？删除后无法恢复！')) { $(this).next().submit() }"
                           class="text-danger ml-10"><i class="fa fa-trash-o"></i> 删除</a>
                        {!! Form::open(['url' => route('admin.destroy', ['id' => $admin->id]), 'method' => 'delete']) !!}
                        {!! Form::close() !!}
                    @endcan
                </td>
            </tr>
        @endforeach
        </tbody>
    @endcomponent
@endsection
